const express = require('express')
const cors = require('cors')
const order = require('./routes/order.js')
const session = require('./routes/session.js')
const news = require('./routes/news.js')
const knowledge = require('./routes/knowledge.js')
const sort = require('./routes/sort.js')
const opinion = require('./routes/opinion.js')
const aq = require('./routes/aq.js')
const image = require('./routes/img')
var path=require("path")

const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost:27017/Rc')

const app = express()
app.use(cors())
app.use(express.json())
app.use(express.urlencoded({extended:true}))

app.use("/news",express.static(__dirname+"/public/news"))
app.use("/konwledge",express.static(__dirname+"/public/konwledge"))

app.use('/api/order',order)
app.use('/api/session',session)
app.use('/api/news',news)
app.use('/api/opinion',opinion)
app.use('/api/knowledge',knowledge)
app.use('/api/aq',aq)
app.use('/api/sort',sort)
app.use('/api/img',image)

app.use("/public",express.static("public"))

app.listen(3000,() => {
     console.log('listen in 3000')
});